﻿using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Input;

namespace FanaticRock.Controls.Primitives
{
    public class FanaticRockWindow : Window
    {
        public FanaticRockWindow()
        {
            WindowStyle = WindowStyle.None;
            AllowsTransparency = true;
            AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(OnClick));
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                DragMove();
            }
        }

        private void OnClick(object sender, RoutedEventArgs args)
        {
            if (args.OriginalSource is ButtonBase buttonBase)
            {
                var tag = buttonBase.Tag as string;
                if (string.IsNullOrWhiteSpace(tag)) return;
                if (tag == "close_window")
                {
                    this.Close();
                }
            }
        }

    }
}
